package homeworkQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url(value(producer("/api/v3/homeworkQuizzes/1")
                , consumer(regex("/api/v3/homeworkQuizzes/\\d+")))) {
            queryParameters {
                parameter("status", "")
            }
        }
    }
    response {
        status(200)
        body("""
        {
            "id": 1,
            "description": "dessss",
            "evaluateScript": "run.sh",
            "templateRepository": "https://github.com/test",
            "makerId": 1,
            "homeworkName": "javascript",
            "answerPath": "https://github.com/testPath",
            "stackId": 1,
            "rawId": 1,
            "answerDescription": "dadasdad",
            "definitionRepo": "https://github.com/repo",
            "status": 1,
            "buildNumber": 1,
            "quizGroupId": 1,
            "remark": "123",
            "jobMessage": "sande",
            "tags": [],
            "available": true,   
        }
        """)
        bodyMatchers {
            jsonPath('$', byType())
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.description', byType())
            jsonPath('$.evaluateScript', byType())
            jsonPath('$.templateRepository', byType())
            jsonPath('$.makerId', byRegex(number()))
            jsonPath('$.homeworkName', byType())
            jsonPath('$.answerPath', byType())
            jsonPath('$.stackId', byRegex(number()))
            jsonPath('$.rawId', byRegex(number()))
            jsonPath('$.answerDescription', byType())
            jsonPath('$.definitionRepo', byType())
            jsonPath('$.status', byType())
            jsonPath('$.buildNumber', byRegex(number()))
            jsonPath('$.quizGroupId', byRegex(number()))
            jsonPath('$.remark', byType())
            jsonPath('$.jobMessage', byType())
            jsonPath('$.tags', byType())
            jsonPath('$.available', byRegex(anyBoolean()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
